import { useEffect, useState } from 'react';
import { buildDeptTree, getDeptList } from '@/services/dept';

export const useDeptModel = () => {
  const [deptTree, setDeptTree] = useState<any[]>([]);
  useEffect(() => {
    fetchDeptTree();
  }, []);
  const fetchDeptTree = async () => {
    const { data } = await getDeptList('sdf');
    setDeptTree(buildDeptTree(data));
  };
  return {
    deptTree,
    fetchDeptTree,
  };
};
